package com.ruoyi.web.controller.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.HisHandCmdWeight;
import com.ruoyi.system.service.IHisHandCmdWeightService;

/**
 * 称重回传Controller	
 * 
 * @author ZYT
 * @date 2020-12-21
 */
@RestController
@RequestMapping("/system/HisHandCmdWeight")
public class HisHandCmdWeightController extends BaseController
{
    @Autowired
    private IHisHandCmdWeightService hisHandCmdWeightService;

    /**
     * 查询称重回传列表
     */
    @PreAuthorize("@ss.hasPermi('system:HisHandCmdWeight:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisHandCmdWeight hisHandCmdWeight)
    {
        startPage();
        List<HisHandCmdWeight> list = hisHandCmdWeightService.selectHisHandCmdWeightList(hisHandCmdWeight);
        return getDataTable(list);
    }

    /**
     * 导出称重回传列表
     */
    @PreAuthorize("@ss.hasPermi('system:HisHandCmdWeight:export')")
    @Log(title = "称重回传", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HisHandCmdWeight hisHandCmdWeight)
    {
        List<HisHandCmdWeight> list = hisHandCmdWeightService.selectHisHandCmdWeightList(hisHandCmdWeight);
        ExcelUtil<HisHandCmdWeight> util = new ExcelUtil<HisHandCmdWeight>(HisHandCmdWeight.class);
        return util.exportExcel(list, "HisHandCmdWeight");
    }

    /**
     * 获取称重回传详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:HisHandCmdWeight:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hisHandCmdWeightService.selectHisHandCmdWeightById(id));
    }

    /**
     * 新增称重回传
     */
    @PreAuthorize("@ss.hasPermi('system:HisHandCmdWeight:add')")
    @Log(title = "称重回传", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HisHandCmdWeight hisHandCmdWeight)
    {
        return toAjax(hisHandCmdWeightService.insertHisHandCmdWeight(hisHandCmdWeight));
    }

    /**
     * 修改称重回传
     */
    @PreAuthorize("@ss.hasPermi('system:HisHandCmdWeight:edit')")
    @Log(title = "称重回传", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HisHandCmdWeight hisHandCmdWeight)
    {
        return toAjax(hisHandCmdWeightService.updateHisHandCmdWeight(hisHandCmdWeight));
    }

    /**
     * 删除称重回传
     */
    @PreAuthorize("@ss.hasPermi('system:HisHandCmdWeight:remove')")
    @Log(title = "称重回传", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hisHandCmdWeightService.deleteHisHandCmdWeightByIds(ids));
    }
}
